/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package components;

import java.awt.BorderLayout;
import java.awt.Font;
import javax.swing.*;
import javax.swing.border.EtchedBorder;

/**
 *
 * @author DYNG09
 */
public class ViewResultPanel extends JScrollPane{
    private JTable tableResult;
    private JScrollPane scroll;
    
    public ViewResultPanel(){
        this.setBorder(new EtchedBorder());
        this.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        this.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        
        this.tableResult = null;
        initGUI();
    }
    
    public void setResult(){
        this.scroll.setViewportView(this.tableResult);
    }
    
    private void initGUI(){
        JPanel topPanel = new JPanel(new BorderLayout());
        
        scroll = new JScrollPane();
        scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        //scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        scroll.setViewportView(getTableResult());
        
        JLabel title = new JLabel("View result");
        title.setFont(new Font("Times New Roman", 1, 20));
        title.setHorizontalAlignment(SwingConstants.CENTER);
        
        topPanel.add(title, BorderLayout.PAGE_START);
        topPanel.add(scroll, BorderLayout.CENTER);
        
        this.setViewportView(topPanel);
    }

    /**
     * @return the tableResult
     */
    public JTable getTableResult() {
        return tableResult;
    }

    /**
     * @param tableResult the tableResult to set
     */
    public void setTableResult(JTable tableResult) {
        this.tableResult = tableResult;
    }
}
